﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Maticsoft.DBUtility;
using System.Data.SqlClient;
using System.Data;

namespace ElingOA6_Admin_DSJCJ.DAL
{
    /// <summary>
    /// 
    /// </summary>
    public class PeerReviewInit
    {
        /// <summary>
        /// 
        /// </summary>
        public void Init(decimal peerReviewID, string entityNo)
        {
            StringBuilder strSql = new StringBuilder();
            CommandInfo cmds = new CommandInfo();
            List<CommandInfo> cmdList = new List<CommandInfo>();
            strSql.Append("EXEC dbo.sp_initPeerReview");
            SqlParameter[] abd = { new SqlParameter() };
            cmds.CommandText = strSql.ToString();
            cmds.Parameters = abd;
            cmdList.Add(cmds);

            //strSql = new StringBuilder();
            //strSql.Append("update dbo.t_PeerReview set ");
            //strSql.Append("FBeginDate=@FBeginDate,FEndDate=@FEndDate ");
            //strSql.Append("where FPeerReviewID=@FPeerReviewID ");

            //SqlParameter[] parameters = {
            //        new SqlParameter("@FBeginDate", SqlDbType.DateTime),
            //        new SqlParameter("@FEndDate", SqlDbType.DateTime),
            //        new SqlParameter("@FPeerReviewID", SqlDbType.Decimal,13)};
            //parameters[0].Value = DBNull.Value;
            //parameters[1].Value = DBNull.Value;
            //parameters[2].Value = peerReviewID;
            //cmds.CommandText = strSql.ToString();
            //cmds.Parameters = parameters;
            //cmdList.Add(cmds);

            //把评分表的FStatus的字段改为N
            strSql = new StringBuilder();
            cmds = new CommandInfo();
            strSql.Append("update dbo.t_PeerReviewVoter set");
            strSql.Append(" FStatus='N',FVoteDate=@FVoteDate,FVoteIP=@FVoteIP where FEntityNo=@FEntityNo ");
            SqlParameter[] parameters = {
                          new SqlParameter("@FEntityNo", SqlDbType.NVarChar),
                          new SqlParameter("@FVoteDate", SqlDbType.DateTime),
                          new SqlParameter("@FVoteIP", SqlDbType.NVarChar) 
                                        };
            parameters[0].Value = entityNo;
            parameters[1].Value = DBNull.Value;
            parameters[2].Value = DBNull.Value;
            cmds.CommandText = strSql.ToString();
            cmds.Parameters = parameters;
            cmdList.Add(cmds);

            DbHelperSQL.ExecuteSqlTranWithString(cmdList);
        }

    }
}
